﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Urb.Weather.Core.MeasureUnit;

namespace Urb.Weather.Ticker.UI.Converters
{
    [ValueConversion(typeof(PressureUnit), typeof(string))]
    public class PressureUnitConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || !(value is PressureUnit))
                return string.Empty;

            var pressureUnit = (PressureUnit)value;

            switch (pressureUnit)
            {
                case PressureUnit.HPa:
                    return "hPa";
                case PressureUnit.Milibar:
                    return "mb";
                case PressureUnit.InchHg:
                    return "in";
                default:
                    return "unknown";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
